Material/shader like selection outlines

Hi, i was wondering if anyone knows how i could create a material exactly like what you see when you click an object in the viewport and it is highlighted with a selection outline, This cannot be achieved with a toon material as i need the outline to be visible behind other objects, just like the viewport selection outlines. this is very handy for showing components that are hidden behind other objects.

Currently i am just taking a screenshot but this is not ideal as the image needs to line up perfectly with other rendered images from the tradition render and they just never do due to the cropping that will happen when taking screenshots.

it may be possible to find the actual selection outlines shader and convert it to a material… not sure but any suggestions would be welcome
Thanks in advance.

Render the part with toon outlines as separate file, assemble in postproduction.

Yes, i could do that- i was just looking for a time saving method via a material, since clearly it can be done because it does it in the main viewport.

One distinction is that the toon shader is actually a material happening in the render engine (3D scene space) whereas selection outlines are happening in the user interface, on the 2D picture plane. So, while they look like the same outcome, they’re handled/calculated quite differently I believe.

Put the part on a render layer to get it isolated as a separate layer. A simple layer option in post would add the outline very easy.